/**
 * ControladoraResponsable.java
 */

 /**
 *  AdSec: Administrador de Secundarias
 *  Copyright (C) 2009 Daniela Ramírez Chaves (dannyrch@gmail.com)
 *  Copyright (C) 2009 Leonel Salazar Valverde (leo87sv@gmail.com)
 *
 *  This file is part of AdSec.
 *  AdSec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AdSec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AdSec.  If not, see <http://www.gnu.org/licenses/>.
 */

package adsec.negocios;
import java.util.LinkedList;
import adsec.datos.ControladoraBDResponsable;
import adsec.entidades.Responsable;


public class ControladoraResponsable {

    private ControladoraBDResponsable controladoraBD;

    public ControladoraResponsable(){
        this.controladoraBD = new ControladoraBDResponsable();

    }//fin de constructor

    public Responsable consultarResponsable(String cedula){
        Responsable responsable;
        responsable = this.controladoraBD.consultarResponsable(cedula);
        return responsable;
    }//fin de consultarResponsable

    public LinkedList<Responsable> consultarResponsables(String cedulaEstudiante){
        LinkedList<Responsable> lista;
        lista = this.controladoraBD.consultarResponsables(cedulaEstudiante);
        return lista;
    }//fin de consultarResponsables

    public int insertarResponsable(Responsable responsable, String estudiante){
        int resultado = this.controladoraBD.insertarResponsable(responsable);
        if(resultado == UtilidadesCapaNegocios.QUERY_OK){
            resultado = this.controladoraBD.insertarRelacionEstudianteResponsable(responsable.getCedula(), estudiante);
            if(resultado == UtilidadesCapaNegocios.QUERY_ERROR){
                this.eliminarResponsable(estudiante);
            }
        }
        return resultado;
    }//fin de insertarResponsable

    public int modificarResponsable(Responsable responsable){
        int resultado = 0;
        resultado = this.controladoraBD.modificarResponsable(responsable);
        return resultado;
    }//fin de modificarResponsable

    public int eliminarResponsable(String cedula){
        int resultado = 0;
        resultado = this.controladoraBD.eliminarResponsable(cedula);
        return resultado;
    }//fin de eliminarResponsable

}//fin de ControladoraResponsable
